#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h> //write 的头文件


#define LOG "log.txt" //日志文件
#define SIZE 32

int main()
{
  int fd=open(LOG,O_WRONLY | O_CREAT | O_TRUNC,0666);
  if(fd == -1)
  {
    perror("open file failed");
    exit(-1);
  }
  const char* ps ="Hello World!\n";
  int cnt=3;
  while(cnt--)
  {
    write(fd,ps,strlen(ps));

  }
  printf("%d\n",fd);
  close(fd);
  return 0;
}
